﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;


public partial class appleader_weight_directRule : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        int projectid = Convert.ToInt32(Session["currentprojectid"].ToString());
            DataTable dt = MasApp.BLL.Search.SearchRuleIDandName(projectid);
          MasApp.Model.weight we=new MasApp.Model.weight();
        we.Weightmissionid=MasApp.BLL.Search.SearchWeightMissionID(Convert.ToInt32(Session["currentprojectid"].ToString()));
        we.Elementtype="准则";

        float allweight=0;
        for (int jj = 0; jj < dt.Rows.Count; jj++)
        {
            allweight += Convert.ToSingle(Convert.ToInt32(dt.Rows[jj][0].ToString()));
        }
        for (int j = 0; j < dt.Rows.Count; j++)
        {
            we.Elementid = Convert.ToInt32(dt.Rows[j][0].ToString());
            we.Weightvalue = (Convert.ToSingle(Request[we.Elementid.ToString()].ToString())) / (allweight);
            MasApp.BLL.Update.UpdateWeight(we);
        }
        MasApp.BLL.ResponseHelper.alert("修改完成！", "directRule.aspx?projectid=" + Session["currentprojectid"].ToString());
    }
    public void wri()
    {

        if (Request["projectid"] != null)
        {
            int projectid = Convert.ToInt32(Request["projectid"].ToString());
            DataTable dt = MasApp.BLL.Search.SearchRuleIDandName(projectid);

            Response.Write("<table width=60%>");
            Response.Write("<tr><td width=50%>准则名称</td><td width=50%>当前权值</td></tr>");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Response.Write("<tr><td>" + dt.Rows[i][1].ToString() + "</td><td><input id='"
                    + dt.Rows[i][0].ToString() + "' name='" + dt.Rows[i][0].ToString() + "' type='text' /></td></tr>");
            }
            Response.Write("</table>");
            dt.Dispose();
            Session["currentprojectid"]=projectid;
        }
    }
}
